package cn.felord.command;

public class Client {

    public static void main(String[] args) {
        Receiver cook = new Cook();
        Command eatCommand = new ConcreteCommand(cook);
        // 吃龙虾
        action(eatCommand);

        Receiver bartender = new Bartender();
        Command drinkCommand = new ConcreteCommand(bartender);
        // 喝小酒
        action(drinkCommand);


        // 复合逻辑  同时叫龙虾和小酒

        CompositeCommand compositeCommand = new CompositeCommand();

        compositeCommand.addReceiver(cook);
        compositeCommand.addReceiver(bartender);
        action(compositeCommand);


    }

    /**
     * 业务流程 无论业务怎么变化 始终只需要传入命令即可 
     * 扩展性强，请求和执行相互解耦
     */
    private static void action(Command command) {

        Invoker waiter = new Waiter(command);

        waiter.action();

    }


}
